package com.example.service1.provider.listener;

import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
import org.springframework.cloud.client.discovery.event.InstancePreRegisteredEvent;
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import javax.servlet.annotation.WebListener;

/**
 * @WebListener 注解是要实现监听器接口，才加这个注解
 */
@Component
public class Service1StateListener {


    @EventListener
    public void listen(HeartbeatEvent event) {
        System.out.println("心跳事件："+event);
    }

    @EventListener
    public void listen(InstancePreRegisteredEvent event) {
        System.out.println("注册服务前事件："+event);
    }

    @EventListener
    public void listen(InstanceRegisteredEvent event) {
        System.out.println("服务注册后事件："+event);
    }


}
